package figury;

import java.util.Scanner;

public class Prostokat implements Pole {

    private double a;
    private double b;
    private double pole;

    public void pole() {
        int c;
        int d;
        System.out.println("Podaj pierwszy bok prostokąta:");
        Scanner bok1 = new Scanner(System.in);
        a = bok1.nextDouble();
        System.out.println("Podaj drugi bok prostokąta:");
        Scanner bok2 = new Scanner(System.in);
        b = bok2.nextDouble();
        c = (int) a;
        d = (int) b;
        pole = a * b;
        if (a % c == 0 && b % d == 0) {
            System.out.printf("Prostokat o bokach a=" + c + " i b=" + d + " ma pole o wartości P=%.0f", pole);
            System.out.println();
        } else if (a % c == 0 && (b % d) != 0) {
            System.out.printf("Prostokat o bokach a=" + c + " i b=" + b + " ma pole o wartości P=%.2f", pole);
            System.out.println();
        } else if (a % c != 0 && (b % d) == 0) {
            System.out.printf("Prostokat o bokach a=" + a + " i b=" + d + " ma pole o wartości P=%.2f", pole);
            System.out.println();
        } else {
            System.out.printf("Prostokat o bokach a=" + a + " i b=" + b + " ma pole o wartości P=%.2f", pole);
            System.out.println();
        }
    }
}
